<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增教务班级')"/>
    <th:block th:include="include :: datetimepicker-css"/>

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-classes-add">
        <input name="schoolId" type="hidden" th:value="${schoolId}">
        <div class="form-group">
            <label class="col-sm-3 control-label">课程：</label>
            <div class="col-sm-7">
                <select name="courseId" class="form-control" required>
                    <option th:each="teacherCourse:${courses}" th:value="${teacherCourse.courseId}"
                            th:text="${teacherCourse.name}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">班级名：</label>
            <div class="col-sm-7">
                <input name="className" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">满班人数：</label>
            <div class="col-sm-2" style="width: 70px">
                <input name="maxStudent" class="form-control" type="number" value="1" style="width: 50px" min="1">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">每天上课：</label>
            <label class="col-sm-1 control-label" style="width: 82px">学生消耗</label>
            <div class="col-sm-1" style="width: 70px; padding: inherit">
                <input name="studentConsume" class="form-control" type="number" style="width: 50px" min="1" value="1">
            </div>
            <label class="control-label">课时</label>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"> </label>
            <label class="col-sm-3 control-label" style="width: 82px">老师获得</label>
            <div class="col-sm-2" style="width: 70px; padding: inherit">
                <input name="teacherIncrease" class="form-control" type="number" style="width: 50px" min="1" value="1">
            </div>
            <label class="control-label">课时</label>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">招生状态：</label>
            <div class="col-sm-7">
                <select name="status" class="form-control" th:with="type=${@dict.getType('sys_classes_status')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">开班日期：</label>
            <div class="col-sm-7">
                <div class="input-group date">
                    <input name="startDate" th:value="${#dates.format(new java.util.Date(), 'yyyy-MM-dd')}"
                           class="form-control" placeholder="请选择日期" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">结班日期：</label>
            <div class="col-sm-7">
                <div class="input-group date">
                    <input name="endDate" class="form-control" placeholder="请选择日期" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-7">
                <textarea name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">
    var prefix = ctx + "teaching/classes"
    $("#form-classes-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-classes-add").serializeArray();
            var courseName = $("select[name='courseId']").find("option:selected").text();
            var schoolId = $("input[name='schoolId']").val();
            data.push({"name": "schoolId", "value": schoolId});
            data.push({"name": "courseName", "value": courseName});
            $.operate.save(prefix + "/add", data);
        }
    }

    $("input[name='startDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true,
        initialDate: new Date()
    });

    $("input[name='endDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='teachTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    // $(function () {
    //     $('#courseId').select2({
    //         placeholder: "请选择课程",
    //         allowClear: true
    //     });
    // });
</script>
</body>
</html>